package com.gas.project.gas.morality.service.impl;

import java.util.List;

import com.gas.common.utils.DateUtils;
import com.gas.common.utils.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gas.project.gas.morality.mapper.MoralityMapper;
import com.gas.project.gas.morality.domain.Morality;
import com.gas.project.gas.morality.service.IMoralityService;

/**
 * 奖惩信息Service业务层处理
 *
 * @author xyl
 * @date 2022-04-04
 */
@Service
public class MoralityServiceImpl implements IMoralityService {
    @Autowired
    private MoralityMapper moralityMapper;

    /**
     * 查询奖惩信息
     *
     * @param moralityId 奖惩信息ID
     * @return 奖惩信息
     */
    @Override
    public Morality selectMoralityById(Long moralityId) {
        return moralityMapper.selectMoralityById(moralityId);
    }

    /**
     * 查询奖惩信息列表
     *
     * @param morality 奖惩信息
     * @return 奖惩信息
     */
    @Override
    public List<Morality> selectMoralityList(Morality morality) {
        return moralityMapper.selectMoralityList(morality);
    }

    /**
     * 新增奖惩信息
     *
     * @param morality 奖惩信息
     * @return 结果
     */
    @Override
    public int insertMorality(Morality morality) {
        morality.setCreateTime(DateUtils.getNowDate());
        return moralityMapper.insertMorality(morality);
    }

    /**
     * 修改奖惩信息
     *
     * @param morality 奖惩信息
     * @return 结果
     */
    @Override
    public int updateMorality(Morality morality) {
        morality.setUpdateTime(DateUtils.getNowDate());
        return moralityMapper.updateMorality(morality);
    }

    /**
     * 删除奖惩信息对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMoralityByIds(String ids) {
        return moralityMapper.deleteMoralityByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除奖惩信息信息
     *
     * @param moralityId 奖惩信息ID
     * @return 结果
     */
    @Override
    public int deleteMoralityById(Long moralityId) {
        return moralityMapper.deleteMoralityById(moralityId);
    }

    @Override
    public String importMorality(List<Morality> moralityList) {
        for (Morality morality : moralityList) {
            moralityMapper.insertMorality(morality);
        }
        return "导入成功！";
    }
}
